/**click
 * $Id: Actions.js,v 1.33 2012-06-30 05:47:52 gaudenz Exp $
 * Copyright (c) 2006-2012, JGraph Ltd
 */
/**
 * Constructs the actions object for the given UI.
 */
function Actions(editorUi, items, itemStyles, sqlNameTest, sqlNameValue, systemEntityText, systemEntityValue, openManga)
{
    this.editorUi = editorUi;
    this.actions = new Object();


    this.items = items;
    this.itemStyles = itemStyles;
    this.sqlNameTest = sqlNameTest;
    this.sqlNameValue = sqlNameValue;
    this.systemEntityText = systemEntityText;
    this.systemEntityValue = systemEntityValue;


    this.openManga = openManga;

    this.init();


}

/**
 * Adds the default actions.
 */

Array.prototype.remove = function() {
    var what, a = arguments, L = a.length, ax;
    while (L && this.length) {
        what = a[--L];
        while ((ax = this.indexOf(what)) != -1) {
            this.splice(ax, 1);
        }
    }
    return this;
}



var ui;
var graph;

var systemEntityText;
var systemEntityValue;
var sqlNameValue;
var sqlNameTest;
function ShowManagedItems() {

    ui.showDialog(new UpdateManagedItems(ui, graph, sqlNameTest, sqlNameValue, systemEntityText, systemEntityValue).container, 750, 450, true, true);

   
}





Actions.prototype.init = function()
{

    ui = this.editorUi;
    var editor = ui.editor;
    graph = editor.graph;

    var items = this.items;
    var itemStyles = this.itemStyles;

    sqlNameValue = this.sqlNameValue;
    sqlNameTest = this.sqlNameTest;

    var openManga = this.openManga;



    systemEntityText = this.systemEntityText;
    systemEntityValue = this.systemEntityValue;


    $(".cancelitem").click(function() {
        $(".itemWindow").hide();

    });





    $(".showManagedItems").click(function() {



        ShowManagedItems();


    });



    $(function() {



        ui.showDialog(new UpdateManagedItems(ui, graph, sqlNameTest, sqlNameValue, systemEntityText, systemEntityValue).container, 750, 450, true, true);

    });




};

/**
 * Registers the given action under the given name.
 */
Actions.prototype.addAction = function(key, funct, enabled, iconCls, shortcut)
{
    return this.put(key, new Action(mxResources.get(key), funct, enabled, iconCls, shortcut));
};

/**
 * Registers the given action under the given name.
 */
Actions.prototype.put = function(name, action)
{
    this.actions[name] = action;

    return action;
};

/**
 * Returns the action for the given name or null if no such action exists.
 */
Actions.prototype.get = function(name)
{
    return this.actions[name];
};

/**
 * Constructs a new action for the given parameters.
 */
function Action(label, funct, enabled, iconCls, shortcut)
{
    mxEventSource.call(this);
    this.label = label;
    this.funct = funct;
    this.enabled = (enabled != null) ? enabled : true;
    this.iconCls = iconCls;
    this.shortcut = shortcut;
}
;

// Action inherits from mxEventSource
mxUtils.extend(Action, mxEventSource);

/**
 * Sets the enabled state of the action and fires a stateChanged event.
 */
Action.prototype.setEnabled = function(value)
{
    if (this.enabled != value)
    {
        this.enabled = value;
        this.fireEvent(new mxEventObject('stateChanged'));
    }
};

/**
 * Sets the enabled state of the action and fires a stateChanged event.
 */
Action.prototype.setToggleAction = function(value)
{
    this.toggleAction = value;
};

/**
 * Sets the enabled state of the action and fires a stateChanged event.
 */
Action.prototype.setSelectedCallback = function(funct)
{
    this.selectedCallback = funct;
};

/**
 * Sets the enabled state of the action and fires a stateChanged event.
 */
Action.prototype.isSelected = function()
{
    return this.selectedCallback();
};
